<template>
	<div class="menutree">
		<el-tree
     style="background-color: #21325e;"
     ref="tree"
     node-key="key"
     :default-expanded-keys="defaultShowNodes"
     accordion
     :highlight-current="true"
     :data="dataList"
     :props="defaultProps"
			@node-click="handleNodeClick"></el-tree>
	</div>
</template>

<script>
	export default {
		name: "menutree",
		props: {
		},
		data() {
			return {
        defaultShowNodes:[],
        dataList:[],
				defaultProps: {
					children: 'children',
					label: 'title'
				}
			};
		},
		methods: {
			load(data) {
        this.defaultShowNodes = data.defaultShowNodes
        this.dataList = data.treeList
			},
			// recordId(menu) {
			// 	let type = sessionStorage.getItem("type");
			// 	if (type == 0) {
			// 		this.recordProgram(menu)
			// 	} else {
			// 		this.recordVariety(menu)
			// 	}
			// },
			// recordVariety(menu) {
			// 	if (menu.index == 2 && menu.columnType == 2) {
			// 		let kindId = sessionStorage.getItem("kindId")
			// 		if (kindId != null && kindId != menu.key) {
			// 			sessionStorage.removeItem('index')
			// 			sessionStorage.removeItem('programId')
			// 		}
			// 		sessionStorage.setItem("kindId", menu.key)
			// 	}
			// 	if (menu.columnType == 1) {
			// 		sessionStorage.setItem("programId", menu.key)
			// 	}
			// },
			// recordProgram(menu) {
			// 	if (menu.columnType == 1) {
			// 		if (menu.children == null) {
   //          this.defaultShowNodes = []
			// 			sessionStorage.removeItem("kindId")
			// 			sessionStorage.removeItem("index")
			// 			sessionStorage.removeItem("programId")
			// 		}
			// 		let index = sessionStorage.getItem('index', menu.index)
			// 		if (index == null) {
			// 			sessionStorage.setItem('index', menu.index)
			// 			sessionStorage.setItem("programId", menu.key)
			// 		} else if (index <= menu.index) {
			// 			sessionStorage.setItem('index', menu.index)
			// 			sessionStorage.setItem("programId", menu.key)
			// 		}
			// 	}
			// 	if (menu.columnType == 2) {
			// 		sessionStorage.setItem("kindId", menu.key)
			// 	}
			// },
			handleNodeClick(menu) {
				// this.recordId(menu)
        if(menu.children == null){
          let kindId = menu.kindId;
          let programId = menu.programId;
          console.log(kindId)
          console.log(programId)
          let url = '/chart'
          if(programId != null){
            url = url + "?programId=" + programId
            if(kindId != null){
              url = url + "&kindId=" + kindId
            }
          }
          console.log("跳转本页面携带参数")
          this.$router.push({
          	path: url
          })
        }

			}
		}
	};
</script>

<style lang="scss">
	.el-tree-node__label {
		color: #ffffff;
	}
  .el-tree {
      position: relative;
      cursor: default;
      background: #FFF;
      color: #606266;
  }
	.is-expanded {
		background-color: #0f1525;
	}

	.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content,
	.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
		background-color: #0f1525;
	}

	.el-tree-node__content:hover {
		background-color: #0f1525;
	}

	.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content:active,
	.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content:active {
		background-color: #0f1525;
	}

	.el-tree-node:focus>.el-tree-node__content {
		background-color: #0f1525
	}

	.el-tree-node__content {
		height: 45px;

	}
</style>
